package com.kw.sqlsession;

import com.kw.config.XMlConfigBuilder;
import com.kw.pojo.Configuration;
import org.dom4j.DocumentException;

import java.io.InputStream;

/**
 * Created by Medivh on 2020/5/7.
 * 愿我出走半生,归来仍是少年
 */
public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(InputStream in) throws DocumentException {
        //step1.解析
         XMlConfigBuilder xmlConfigBuilder  =  new XMlConfigBuilder();
         Configuration configuration = xmlConfigBuilder.parseConfig(in);


        //step2.创建sqlsessionFactory对象
        DefaultSqlSessionFactory defaultSqlSessionFactory  = new DefaultSqlSessionFactory(configuration);



        return  defaultSqlSessionFactory;

    }
}
